Skip to content

Implement easier change of bank account#94019

Merged
robertjchen merged 65 commits into
Expensify:mainfrom
callstack-internal:feat/79607-easier-change-of-bank-account
Jul 20, 2026
Merged

Implement easier change of bank account#94019
robertjchen merged 65 commits into
Expensify:mainfrom
callstack-internal:feat/79607-easier-change-of-bank-account

Conversation

@VickyStash

@VickyStash VickyStash commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Workspace admins can now switch their reimbursement bank account directly from the connected/verified bank account screen, without disconnecting the current account first.

A new "Change bank account" option is added to the connected verified bank account screen. When pressed:

  • If the workspace has other eligible existing business bank accounts , the user is taken to the existing-account picker. The currently connected account is hidden from this list.
  • If there are no other eligible accounts, the user goes straight into the flow to set up a brand-new bank account.

Fixed Issues

$ #79607
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console

Setup: a workspace (USD) where you're an admin, and at least one business bank account already connected to your account.

1.Workflows → Payments -> Add bank account.
2. Select the account that is already set up.

Change BA → Add BA (new account) → links to workspace

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Tap Log into your bank account, proceed with the Plaid BA setup flow.
  4. Verify: after finishing, the newly added account is linked to Workflows → Payments for that workspace.

Change BA → pick an existing account → links to workspace

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Select another BA
  4. Verify selected account is now shown as the bank account for Workflows → Payments

Add partially set up bank account (add bank account, but don't provide personal info).

Change BA → pick an partially setup account

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Select another partially setup BA
  4. Verify selected account is now shown as the bank account for Workflows → Payments
  5. Verify you see Almost done page.
  6. Close the modal.
  7. Tap on BA.
  8. See you pushed to Almost done page with Change bank account row.
  9. Change the BA to set up BA and verify it works.

Offline tests

Same, as in Tests section

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

Same, as in Tests section

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android_pt1.mp4
android_pt2.mp4
Android: mWeb Chrome
android_web_pt1.mp4
android_web_pt2.mp4
iOS: Native
ios_pt1.mov
ios_pt2.mov
iOS: mWeb Safari
ios_web_pt1.mov
ios_web_pt2.mov
MacOS: Chrome / Safari
web_pt1.mp4
web_pt2.mp4

koko57 and others added 25 commits February 2, 2026 11:15
…llstack-internal/Expensify-App into feat/79607-easier-change-of-bank-account
…k-internal/Expensify-App into feat/79607-easier-change-of-bank-account
# Conflicts:
#	src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx
@melvin-bot

melvin-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

# Conflicts:
#	src/libs/actions/ReimbursementAccount/index.ts
#	src/pages/ReimbursementAccount/ConnectedVerifiedBankAccount.tsx
#	src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
#	src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/hooks/useChangeBankAccount.ts 100.00% <100.00%> (ø)
src/libs/ExportOnyxState/common.ts 80.35% <ø> (ø)
src/libs/WorkflowUtils.ts 90.83% <100.00%> (+0.03%) ⬆️
src/libs/actions/Policy/Policy.ts 70.00% <100.00%> (-0.05%) ⬇️
src/selectors/ReimbursementAccount.ts 100.00% <100.00%> (ø)
src/ROUTES.ts 21.64% <85.71%> (+0.62%) ⬆️
...rc/libs/actions/ReimbursementAccount/navigation.ts 0.00% <0.00%> (ø)
src/libs/mapCurrencyToCountry.ts 0.00% <0.00%> (ø)
... and 8 more
... and 151 files with indirect coverage changes

Comment thread src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx Outdated
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Review this PR

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@codex
Review this PR

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

Overall this is a well-structured feature — the shared logic is cleanly extracted into useChangeBankAccount, the selector/util changes are focused, and the hook + selector both got unit tests. The bot-flagged items (duplication, the wallet no-op row, VBBA refresh) already look addressed.

My concerns are concentrated in one place: ReimbursementAccountPage, where the "change bank account" flow reuses the same shared reimbursementAccount Onyx data as the connected-account screen and then clobbers it via prepareNewBankAccountSetup. To cope, the page now carries a web of new refs, derived state, and effects — and that is exactly the code with the least test coverage (Codecov confirms the drop there).

Main concerns

  1. Fragile route-string equality guardReimbursementAccountPage.tsx:242 gates fetchData on backTo === ROUTES.BANK_ACCOUNT_CONNECT_EXISTING_BUSINESS_BANK_ACCOUNT.getRoute(policyIDParam). This compares a fully-serialized route string, so it silently stops matching the moment backTo carries any extra param (its own backTo, a source, trailing slash, etc.). Matching on the route/screen name rather than the exact string would be far more robust.

  2. Two overlapping sources of truth for "is changing" — there's the route param isChangingBankAccount and the Onyx flag IS_CHANGING_TO_NEW_BANK_ACCOUNT (isChangingBusinessBankAccount). They model nearly the same intent but gate different branches (display gate L595/L627 vs fetch gate L304). This split is easy to get out of sync later. Worth a comment explaining why both are needed, or deriving one from the other.

  3. Several fetchData() triggers reacting to the same signals — there's now a render-phase setIsSettingBA derived from the loading transition (L131-134), an effect that refetches on that same isLoadingWorkspaceReimbursement transition (L271), a focus-based "data got clobbered" refetch (L288), and the original consume-route-intent effect now guarded by isChangingBusinessBankAccount || isLoadingWorkspaceReimbursement (L304). The code comments acknowledge the races and add guards, but correctness here rests entirely on the ordering in which the various Onyx flags settle. This is the part most likely to regress. Please double-check the fast offline→online and rapid back-navigation cases manually.

  4. Test gap on the risky code — the added tests cover the hook and selector (pure logic that was already low-risk). None cover the ReimbursementAccountPage state machine, which is where the actual complexity/risk lives. Given how race-sensitive this is, a component/integration test exercising the connected → change → (pick existing / new) → return-to-connected transitions would materially de-risk the change.

Minor / nits

  • The Policy.ts additionalData: {policyID} writes are correct with Onyx.METHOD.MERGE (verified), and the NullishDeep<BankAccountList> type change is the right call to allow policyID: null. 👍
  • The connectedBankAccount lookup in ConnectExistingBusinessBankAccountPage.tsx leans on additionalData?.policyID (an optional field) for partially-set-up accounts. It falls back to policy.achAccount.bankAccountID for fully-set-up ones, so it's fine, but it does add coupling to that field being populated — worth keeping in mind.
  • mapCurrencyToCountry returning Country | '' instead of string is a nice tightening. 👍

None of the above are blockers on their own — the feature logic looks sound. The ask is mainly (a) harden the string-equality guard, (b) a short comment reconciling the two "is changing" flags, and (c) ideally one integration test over the page's transitions given the concentrated race risk.

🤖 Generated by MelvinBot — I reviewed the diff and verified specifics against the codebase, but I did not run the app. Treat as a second opinion, not a substitute for manual QA of the flows above.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a127d7fac

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@VickyStash

Copy link
Copy Markdown
Contributor Author

Checking all of the feedback, maybe I'll try to simplify the logic! Also, I haven't solved the second reported issue yet

@VickyStash

Copy link
Copy Markdown
Contributor Author

UPD: still trying to correct the second issue.
There is one issue on the new logic side, but it also looks like there is an existing issue in the same flow. Ex: when I login from account B I see one payment account, if I clear cache and reset data I see another account:

Monosnap.screencast.2026-07-15.18-07-41.mp4

I'm figuring out what goes wrong

@VickyStash

Copy link
Copy Markdown
Contributor Author

I've fixed this: #94019 (comment)
But there is separate existing issue (I've prepared recordings from staging):

  1. Login to account A and invite account B to workspace as admin.
  2. As user A link bank account 1 to workspace -> workflows
  3. Login to account B and set another BA account in the workspace -> workflows
  4. Get back to user A.
    On the workspace -> workflows you see user B BA set, but if you click on it you see another BA on all set page.

Video:

bug_staging.mp4

This happens cause policy has one account set, and user's reimbursementAccount has another one:
1_bug
2_bug

cc @joekaufmanexpensify

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

Hmm, interesting. In your example, if account B changes the Workspace Bank account to Bank account 2 and account A later goes back to the workflows page and taps the bank account row. Wouldn't they then see the option to link a different bank account again?

It's basically the inverse scenario of what Account B originally did to change the Workspace Bank account.

@VickyStash

Copy link
Copy Markdown
Contributor Author

Hmm, interesting. In your example, if account B changes the Workspace Bank account to Bank account 2 and account A later goes back to the workflows page and taps the bank account row. Wouldn't they then see the option to link a different bank account again?

It's basically the inverse scenario of what Account B originally did to change the Workspace Bank account.

Yes, I understand it, but on the video, I provide an example from staging to point out the inconsistency issue. Basically, after user B selects BA 2, it displays for user A on workflows -> payments, but if user A tap on it -> he sees BA1.
The inconsistency is due to policy.achAccount returns one account, and reimbursementAccount.achAccount another one.
See, workflows->payments has 0000 account, but all set displays 1111:
image

Is it expected that returned from BE data has different accounts in policy.achAccount and reimbursementAccount.achAccount. If so, the All set page then should show BA provided in policy.achAccount?

@VickyStash

Copy link
Copy Markdown
Contributor Author

cc @robertjchen wdyt about this one?

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

I agree. Seems odd to me. Discussing more here.

@robertjchen

Copy link
Copy Markdown
Contributor

Is it expected that returned from BE data has different accounts in policy.achAccount and reimbursementAccount.achAccount. If so, the All set page then should show BA provided in policy.achAccount?

Yes, it's expected that it's different. From my understanding:

  • policy.achAccount = the workspace's real, shared payment account (whatever the last admin set)
  • reimbursementAccount.achAccount = a per-user view. The backend re-maps the policy account to a copy the viewing user personally owns (because reimbursement runs under the reimburser's own bank account ID). A doesn't own B's account, so A falls back to their own.

So in this case, the display here should use policy.achAccount 🤔

@VickyStash

Copy link
Copy Markdown
Contributor Author

It was agreed to fix this existing issue in a separate PR.
@ZhenjaHorbach, can you please continue the review of this one?

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Will recheck soon!

@melvin-bot
melvin-bot Bot requested a review from robertjchen July 20, 2026 09:24
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Changes look good!

@robertjchen robertjchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@robertjchen
robertjchen merged commit 44aa54b into Expensify:main Jul 20, 2026
36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 robertjchen has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants